import router from 'umi/router';

import React from 'react';
import { connect } from 'dva';
import Link from 'umi/link'
import { Table, Button } from 'antd';

const linePath = '/AccountStock/Stock';
const formPath = '/AccountStock/StockForm';

@connect(({ accountStock }) => ({ accountStock }))
class List extends React.Component {
  state = {
  }

  treeview = [
      {
        title: '',
        dataIndex: '_',
        render: (_, { id }) => {
          return <Link to={`${linePath}?id=${id}`}>查看</Link>;
        },
      },
      { title: '状态', dataIndex: 'state', },
      { title: '名称', dataIndex: 'name', },
      { title: '日期', dataIndex: 'date', },
      { title: '产品类型', dataIndex: 'product_type', },
      { title: '出入库方向', dataIndex: 'direction', },
      { title: '出库方式', dataIndex: 'move_type', },
      { title: '账簿', dataIndex: 'journal_id.name', },
      { title: '科目', dataIndex: 'account_id.name', },
      { title: '对方科目', dataIndex: 'opp_account_id.name', },
      { title: '金额', dataIndex: 'amount', },
  ]

  async componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'accountStock/search',
      payload: {  //domain:[['move_type','!=','open']],
      },

    });
  }


  goto_createForm() {
      router.push(formPath);
  }


  render() {
    const { accountStock: { recordsList } } = this.props;

    //console.log(recordsList)

    return (
      <div>

        <Button onClick={()=>this.goto_createForm()}>新建</Button>
        <Table columns={this.treeview} dataSource={recordsList} rowKey="id" />


      </div>
    );
  }
}

export default List;





